package com.snopy.jdbc;


import lombok.extern.slf4j.Slf4j;

import java.sql.*;

/**
 * @author snopy
 * @description:
 * @classname Test
 * @date 2020/10/20 15:04
 * @email 77912204@qq.com
 */
@Slf4j
public class DmTest {
    public static void main(String[] args) {


        getConnec();
    }
    public static void getConnec(){
        Connection connection = null;
        try {
            Class.forName("dm.jdbc.driver.DmDriver");
            connection = DriverManager.getConnection("jdbc:dm://192.168.18.75:5236/test","HKYB","shhkyb123");
            //connection.setAutoCommit(false);
            /*boolean readOnly = connection.isReadOnly();
            if(!readOnly){
                connection.setReadOnly(true);
                readOnly = connection.isReadOnly();
                log.info("readOnly?{}",readOnly);
            }*/


            PreparedStatement preparedStatement = connection.prepareStatement(" update RPT_LGYC t set t.jcsj='2021-03-22',t.jl='xxxxx' where t.id ='143' ");

            int execute = preparedStatement.executeUpdate();
            //connection.commit();
            log.info("excuteResult:{}",execute);
            while (true){
                Thread.sleep(1000);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }/*finally {
            if (connection!=null){
                try {
                    connection.close();
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }*/ catch (InterruptedException e) {
            e.printStackTrace();
        }
    }




}
